package com.ruoyi.third.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.third.domain.ThirdConfigField;
import com.ruoyi.third.service.IThirdConfigFieldService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 配置参数Controller
 * 
 * @author yepanpan
 * @date 2025-02-06
 */
@RestController
@RequestMapping("/third/configField")
public class ThirdConfigFieldController extends BaseController
{
    @Autowired
    private IThirdConfigFieldService thirdConfigFieldService;

    /**
     * 查询配置参数列表
     */
    @PreAuthorize("@ss.hasPermi('third:configField:list')")
    @GetMapping("/list")
    public TableDataInfo list(ThirdConfigField thirdConfigField)
    {
        startPage();
        List<ThirdConfigField> list = thirdConfigFieldService.selectThirdConfigFieldList(thirdConfigField);
        return getDataTable(list);
    }

    /**
     * 导出配置参数列表
     */
    @PreAuthorize("@ss.hasPermi('third:configField:export')")
    @Log(title = "配置参数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ThirdConfigField thirdConfigField)
    {
        List<ThirdConfigField> list = thirdConfigFieldService.selectThirdConfigFieldList(thirdConfigField);
        ExcelUtil<ThirdConfigField> util = new ExcelUtil<ThirdConfigField>(ThirdConfigField.class);
        util.exportExcel(response, list, "配置参数数据");
    }


    /**
     * 获取配置参数详细信息
     */
    @PreAuthorize("@ss.hasPermi('third:configField:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(thirdConfigFieldService.selectThirdConfigFieldById(id));
    }

    /**
     * 新增配置参数
     */
    @PreAuthorize("@ss.hasPermi('third:configField:add')")
    @Log(title = "配置参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody ThirdConfigField thirdConfigField)
    {
        return toAjax(thirdConfigFieldService.insertThirdConfigField(thirdConfigField));
    }

    /**
     * 修改配置参数
     */
    @PreAuthorize("@ss.hasPermi('third:configField:edit')")
    @Log(title = "配置参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody ThirdConfigField thirdConfigField)
    {
        return toAjax(thirdConfigFieldService.updateThirdConfigField(thirdConfigField));
    }

    /**
     * 删除配置参数
     */
    @PreAuthorize("@ss.hasPermi('third:configField:remove')")
    @Log(title = "配置参数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(thirdConfigFieldService.deleteThirdConfigFieldByIds(ids));
    }
}
